package com.hxgz.steel.common;

import com.hxgz.steel.service.AskBuyService;
import com.hxgz.steel.service.OrderService;
import com.hxgz.steel.util.PropertiesUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class TimerJob {

    @Autowired
    private OrderService orderService;
    @Autowired
    private AskBuyService abService;

    @Scheduled(cron = "0 */1 * * * ?")
    public void queryPayStatus() {
        /**
         * 修改geo_order字段status 5已关闭
         * 为不干扰其他定时任务的执行
         */
        try {
            int hour = Integer.parseInt(PropertiesUtil.getProperty("close.order.task.time.hour", "1"));
            orderService.closeOrders(hour);
        }catch (Exception e){
            e.printStackTrace();
        }
        /**
         * 修改geo_ask_buy字段status 为1 保价已结束
         */
        abService.listAsks();
    }


}
